<template>
  <div class="container">
    <DataList
      ref="dataList"
      :propAutoFetchData="true"
      :propNoCheck="true"
      :propSearchFields="['materialName','certificateNo', 'materialErpCode']"
      :propSearchTextAppend="'名称/注册证号/ERP编码'"
      propUrl="/base/materials/pageCommon"
      showFieldPk="id"
      :vanFieldLabelWith5="true"
      :showFieldList="cpShowFieldList"
      :sortDefault="{field: 'materialName',type: 'asc'}"
      @click="itemClick"
    >
    </DataList>


    <!--表单-->
    <customDrawer  title="规格列表" ref="customDrawerOrder" :autoHide="false" p94Only placement="right" :footer="null">
      <template #content>
        <DataList
          ref="dataListDtl"
          :propAutoFetchData="false"
          :propNoCheck="true"
          :propSearchFields="['materialSpec','certificateNo']"
          :propSearchTextAppend="'规格、注册证号'"
          propUrl="/base/material_specs/pageCommon"
          :showFieldList="cpDtlshowFieldList"
          :vanFieldLabelWith5="true"
          :sortDefault="{field: 'materialSpec',type: 'asc'}"
        >
        </DataList>
      </template>
    </customDrawer>
  </div>
</template>

<script>

export default {
  help: '商品-列表',
  data() {
    return {
      form: {}
    }
  },

  methods: {
    itemClick(item) {
      this.form = item
      let wrapper = this.$newWrapper()
      wrapper.eq('materialId', this.form.id)
      this.$refs.dataListDtl.setQueryWrapper(wrapper)
      this.$refs.customDrawerOrder.show()
    }
  },
  computed: {
    cpShowFieldList() {

      let fieldList = [
        {label:'名称',name:'materialName',span:24, isTitle: true},
        {
          label:'商品类型',name:'materialTypeCode',span:12,isTitleSub: true,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.baseMatrType,
            multiple: true
          }
        },
        {label:'品类',name:'catalogName',span:12},
        {label:'生产厂商',name:'manufacturerName',span:24},
        {label:'ERP编码',name:'materialErpCode',span:24},
        {label:'注册证号',name:'certificateNo',span:24},
        {label:'注册证开始',name:'certificateExpiredStartDate',span:12,
          queryType: this.constCommon.formItemType.datePickerBetween.name,
        },
        {label:'注册证截止',name:'certificateExpiredDate',span:12,
          queryType: this.constCommon.formItemType.datePickerBetween.name,
        },
        {label:'批准文号',name:'approvalNo',span:12},
      ]
      fieldList = [...fieldList, ...this.constCommon.filterCommon.sp()]
      return fieldList
    },

    // 明细
    cpDtlshowFieldList() {

      let fieldList = [
        {label:'规格',name:'materialSpec',span:24, isTitle: true},
        {label:'ERP编码',name:'materialErpCode',span:24},
        {label:'单价',name:'price',span:12,filterDisabled: true,sortDisabled: true},
        {label:'单品单位',name:'unit',span:12,filterDisabled: true,sortDisabled: true},
        {label:'订单单位',name:'orderUnit',span:12,filterDisabled: true,sortDisabled: true},
        {label:'单位比率',name:'orderQty',span:12,filterDisabled: true,sortDisabled: true},
        {label:'注册证号',name:'certificateNo',span:24},
        {label:'注册证开始',name:'certificateExpiredStartDate',span:12,queryType: this.constCommon.formItemType.datePickerBetween.name},
        {label:'注册证截止',name:'certificateExpiredDate',span:12,queryType: this.constCommon.formItemType.datePickerBetween.name},
        {label:'标签管理',name:'isOneThingOneYard',span:12,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo,
          }},
        {label:'寄售',name:'isConsignment',span:12,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo,
          }},
        {label:'医保代码(20位)',name:'hisMedicareNo',span:24},
        {label:'医保名称(20位)',name:'hisMedicareName',span:24},
        {label:'医保代码(27位)',name:'hisMedicareNo2',span:24},
        {label:'医保名称(27位)',name:'hisMedicareName2',span:24},
      ]
      return fieldList
    }
  }
}
</script>
